//package com.my.lambda;
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONArray;
//import com.alibaba.fastjson.JSONObject;
//import org.apache.catalina.security.SecurityUtil;
//
//import java.util.HashMap;
//
//public class TestFunctionalInterface {
//

//YiBaoServiceImpl
//    @FunctionalInterface
//    interface DecryptObjFun {
//        R decrypt(JSONObject data);
//    }
//    @FunctionalInterface
//    interface DecryptArryFun {
//        R decrypt(JSONArray data);
//    }
//    //    @FunctionalInterface
////    interface DecryptFun<T extends List<?>> {
////        T decrypt(JSONObject data);
////    }
////    @FunctionalInterface
////    interface DecryptFun<T> {
////        T decrypt(JSONObject data);
////    }
//    public R operationObj(HashMap<String,String> map,DecryptObjFun decryptFun){
//        return operation(map,decryptFun,null);
//    }
//    public R operationArr(HashMap<String,String> map,DecryptArryFun decryptFun){
//        return operation(map,null,decryptFun);
//    }
//    public R operation(HashMap<String,String> map,DecryptObjFun decryptObjFun,DecryptArryFun decryptArrFun){
//        map.put("serviceCode", YiBaoServiceImpl.serviceCode);
//        map.put("platId", YiBaoServiceImpl.platId);
//        map.put("publicKeyStr", YiBaoServiceImpl.publicKeyStr);
//
//        HttpResult httpResult = OkHttps.sync(base_url)
//                .addUrlPara(map)
//                .skipSerialPreproc()
//                .tag(YIBAO_TAR)
//                .post();
//        HttpResult.Body body = httpResult.getBody();
//        JSONObject jsonObject = JSON.parseObject(String.valueOf(body));
//        Boolean success = jsonObject.getBoolean("success");
//        if(success) {
//            JSONObject resultData = jsonObject.getJSONObject("resultData");
//            JSONObject data = resultData.getJSONObject("data");
//            String errorCode = data.getString("errorCode");
//            if("0".equals(errorCode)){
//                String decrypt = SecurityUtil.decrypt(data.getInnerMap(), privateKeyStr);
//                if(decryptArrFun!=null){
//                    JSONArray jsonArray = JSON.parseArray(decrypt);
//                    return decryptArrFun.decrypt(jsonArray);
//                }else{
//                    JSONObject dataJsonObject = JSON.parseObject(decrypt);
//                    return decryptObjFun.decrypt(dataJsonObject);
//                }
//            }else{
//                String errorMsg = data.getString("errorMsg");
//                return R.fail(errorMsg);
//            }
//        }
//        throw new ServiceException(jsonObject.toJSONString());
//    }
//
//
//    /**
//     * 获取医保账户余额
//     * @param name 姓名
//     * @param idCard 身份证
//     * @return
//     */
//    @Override
//    public R getAccountBalance(String name, String idCard){
//        HashMap<String,String> map = new HashMap<>();
//        //接口编号
//        map.put("apiNum","GGFWK002");
//        map.put("cardId",idCard);
//        map.put("name",name);
////        {"lists":{},"resultData":{"data":{"errorCode":"0","errorMsg":"","valueData":
////        {"aae240":"149.1"}}},"success":true}
//        R result = operationObj(map, valueData -> {
//            String aae240 = valueData.getString("aae240");
//            return R.data(aae240);
//        });
//        return result;
//    }


//import ch.qos.logback.classic.db.names.TableName;
//import lombok.SneakyThrows;
//
//import java.lang.reflect.Field;
//import java.lang.reflect.Modifier;
//import java.util.ArrayList;
//import java.util.Arrays;
//
//@FunctionalInterface
//interface GeotoolOperation {
//    Object operation(SimpleFeatureStore simpleFeatureStore) throws Exception;
//}
//    @SneakyThrows
//    private SimpleFeatureStore operate(Object o, GeotoolOperation geotoolOperation,Class<T> tClass) {
//        TableName name = tClass.getAnnotation(TableName.class);
//        String tableName = name.value();
//
//        DataStore postgisDataStore = PostgisDataStore.getInstance();
//        SimpleFeatureSource simpleFeatureSource = postgisDataStore.getFeatureSource(tableName);
//        SimpleFeatureStore featureStore = (SimpleFeatureStore) simpleFeatureSource;
//        featureStore.setTransaction(AUTO_COMMIT);
//
//        geotoolOperation.operation(featureStore);
//
//        return featureStore;
//    }
//
//    @SneakyThrows
//    @Override
//    public boolean addFeature(Object val, Class<T> tClass) {
//         SimpleFeatureStore simpleFeatureStores = operate(val, simpleFeatureStore -> {
//            SimpleFeatureType type = simpleFeatureStore.getSchema();
//
//            SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(type);
//            Field[] declaredFields = tClass.getDeclaredFields();
//            for (Field field : declaredFields) {
//                boolean aStatic = Modifier.isStatic(field.getModifiers());
//                if(aStatic){
//                    continue;
//                }
//                String fieldName = field.getName();
//                if(fieldName.equals("id")){
//                    continue;
//                }
//                field.setAccessible(true);
//                TableField annotation = field.getAnnotation(TableField.class);
//                if(annotation!=null){
//                    fieldName = annotation.value();
//                }
//                featureBuilder.set(fieldName,field.get(val));
//            }
//            //构建要素
//            //SimpleFeature feature = featureBuilder.buildFeature("poi1");
//            SimpleFeature feature = featureBuilder.buildFeature(null);
//
//            List<SimpleFeature> features = new ArrayList<>();
//            features.add(feature);
//            SimpleFeatureCollection featureCollection =
//                    new ListFeatureCollection(type,features);
//
//            List<FeatureId> featureIds = simpleFeatureStore.addFeatures(featureCollection);
//            return featureIds;
//        },tClass);
//        return true;
//    }

//}
